<template>
  <div style="background: #212644; height: 60.5px;">
    <!--<router-link :to="{name:'defaultDocSearch'}">-->
    <a href="/defaultDocSearch">
          <span :style="{paddingLeft:'15px'}">
            <span :style="{verticalAlign: 'middle'}"><img style="max-width: 90px; height:43px; margin-top: -10px"
                                                          src="~@/assets/logo-zhis.png" alt="logo"></span>
            <!--<span :style="{verticalAlign: 'middle'}"><img :style="{ maxWidth:'22px'}" src="~@/assets/logo.png" alt="logo"></span>-->
            <!--<span :style="{verticalAlign: 'middle',fontSize: '20px',fontWeight: 'normal',color: 'black',paddingLeft: '10px'}"><b>Smart Aviator</b></span>-->
          </span></a>
    <!--</router-link>-->
    <span v-if="title != '' "
          :style="{verticalAlign: 'middle',fontSize: '20px',fontWeight: 'normal',color: '#FFFFFF',paddingLeft: '10px'}"> -> {{ title }} </span>

    <!--<span @click="jumpManage()">-->
    <span>
      <user-menu :style="{verticalAlign: 'middle',fontSize: '15',fontWeight: 'normal',color: '#FFFFFF',float:'right'}"
                 style="background: #081C42; right: 100px; color: white;
     float: right; width: 100px; text-align: center; height: 60.5px; margin-right: -15px"/>
    </span>


    <span style="float: right;margin-top: 3px;">
                  <span style="margin-right: 20px;cursor: pointer;" @click="gbispace">
        <span style="margin-right: -10px; margin-left: -10px">
           <a-icon theme="twoTone" type='fire' title="GBI" :style="{ fontSize:'25px',minWidth:'40px'}"/>
        </span>
                    <!--<span style="font-size: 14px;cursor: pointer;color: #ffffff;">-->
                    <!--GBI-->
                    <!--</span>-->
      </span>
            <span style="margin-right: 20px;cursor: pointer;" @click="wikispace">
        <span style="margin-right: -10px; margin-left: -10px">
           <a-icon theme="twoTone" type='smile' title="wiki空间" :style="{ fontSize:'25px',minWidth:'40px'}"/>
        </span>
              <!--<span style="font-size: 14px;cursor: pointer;color: #ffffff;">-->
              <!--WIKI空间-->
              <!--</span>-->
      </span>
            <span style="margin-right: 20px;cursor: pointer;" @click="IAmodel">
        <span style="margin-right: -10px; margin-left: -10px">
           <a-icon theme="twoTone" type='rocket' title="IA模型" :style="{ fontSize:'25px',minWidth:'40px'}"/>
        </span>
              <!--<span style="font-size: 14px;cursor: pointer;color: #ffffff;">-->
              <!--AI模型-->
              <!--</span>-->
      </span>
      <span style="margin-right: 20px;cursor: pointer;" @click="drawer = true">
        <span style="margin-right: -10px; margin-left: -10px">
           <a-icon theme="twoTone" type='star' title="收藏夹" :style="{ fontSize:'25px',minWidth:'40px'}"/>
        </span>
        <!--<span style="font-size: 14px;cursor: pointer;color: #ffffff;">-->
        <!--收藏夹-->
        <!--</span>-->
      </span>
      <span style="margin-right: 20px;cursor: pointer;" @click="jumpDraftsPage">
        <span style="margin-right: -10px; margin-left: -10px">
           <a-icon theme="twoTone" type='folder' title="上传文件" :style="{ fontSize:'25px',minWidth:'40px'}"/>
        </span>
        <!--<span style="font-size: 14px;cursor: pointer;color: #ffffff;">-->
        <!--上传文件-->
        <!--</span>-->
      </span>

      <span style="margin-right: 20px;cursor: pointer;" @click="jumpManage">
        <span style="margin-right: -10px; margin-left: -10px">
           <a-icon theme="twoTone" type='setting' title="后台" :style="{ fontSize:'25px',minWidth:'40px'}"/>
        </span>
        <!--<span style="font-size: 14px;cursor: pointer;color: #ffffff;">-->
        <!--后台-->
        <!--</span>-->
      </span>

    </span>
    <a-drawer
      title="收藏夹"
      :visible="drawer"
      @close="onClose"
      width="40%"
    >
      <km-doc-favourite-list v-if="drawer"></km-doc-favourite-list>
    </a-drawer>
  </div>
</template>

<script>
  import {ajaxGetDictItems, getDictItemsFromCache} from '@/api/api'
  import UserMenu from '@/components/tools/UserMenu'
  import {mixin} from '@/utils/mixin.js'
  import KmDocFavouriteList from '@/views/km/filemanagement/KmDocFavouriteList'
  import UserList from '@/views/system/UserList'

  export default {
    name: "SearchHeader",
    mixins: [mixin],
    components: {KmDocFavouriteList, UserMenu, UserList},
    props: {
      title: {
        type: String,
        required: false,
        default: ''
      },
      theme: {
        type: String,
        required: false,
        default: 'white'
      }
    },
    data() {
      return {
        drawer: false,
        wikispaces: "",
        IAmodes: "",
        gbispaces: "",
        dictWiki: 'Wikispace',
        dictIa: 'IAmode',
        dictGbi: 'GBI',
        optWiki: [],
        optIA: [],
        optGBI: [],
      }
    },
    created() {
      this.initOptWiki();
      this.initOptIA();
      this.initOptGBI();
    },
    computed: {},

    methods: {

      onClose() {
        this.drawer = false
      },
      // 进入管理首页
      jumpManage() {
        // this.$router.push('/dashboard/analysis');
        window.open('/dashboard/analysis', '_blank');
      },
      // 跳转到收藏夹
      jumpKmDocFavouritePage() {
        // this.$router.push('/km/filemanagement/KmDocFavouriteList');
      },
      // 跳转到个人草稿文件夹
      jumpDraftsPage() {
        this.$router.push('/CreateDocuments');
      },
      //跳转GBI页面
      gbispace() {
        console.log("----this.gbispaces----" + JSON.stringify(this.gbispaces))
        window.open(this.gbispaces, '_blank');
      },
      //跳转wiki空间页面
      wikispace() {
        window.open(this.wikispaces, '_blank');
      },
      //跳转IA模型页面
      IAmodel() {
        window.open(this.IAmodes, '_blank');
      },

      initOptWiki() {
        this.optWiki = [];
        //优先从缓存中读取字典配置
        if (getDictItemsFromCache(this.dictWiki)) {
          let optWiki = getDictItemsFromCache(this.dictWiki)
          optWiki.forEach((item, index) => {
            let person = {};
            person.label = item.title;
            person.value = item.value;
            this.optWiki.push(person);
            this.wikispaces = this.optWiki[0].value
          });
          return
        }
      },

      initOptIA() {
        this.optIA = [];
        //优先从缓存中读取字典配置
        if (getDictItemsFromCache(this.dictIa)) {
          let optIA = getDictItemsFromCache(this.dictIa)
          optIA.forEach((item, index) => {
            let person = {};
            person.label = item.title;
            person.value = item.value;
            this.optIA.push(person);
            this.IAmodes = this.optIA[0].value
          });
          return
        }
      },

      initOptGBI() {
        this.optGBI = [];
        //优先从缓存中读取字典配置
        if (getDictItemsFromCache(this.dictGbi)) {
          let optGBI = getDictItemsFromCache(this.dictGbi)
          optGBI.forEach((item, index) => {
            let person = {};
            person.label = item.title;
            person.value = item.value;
            this.optGBI.push(person);
            this.gbispaces = this.optGBI[0].value
          });
          return
        }
      },

    }
  };
</script>

